<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<!-- HTML file produced from file: manual.tex --
 -- using Hyperlatex v 2.3.1 (c) Otfried Cheong--
 -- on Emacs 21.4 (patch 12) "Portable Code" XEmacs Lucid, Wed Jun  2 18:56:58 2004 -->
<HEAD>
<TITLE>Scheme 48 Manual -- Queues</TITLE>

</HEAD><BODY BGCOLOR="#ffffff">
<EM>Scheme 48 Manual</EM> | <A HREF="s48manual.html#top_node">Contents</A> | In Chapter: <A HREF="s48manual_35.html">Libraries</A><BR>Previous: <A HREF="s48manual_42.html">Cells</A> | Next: <A HREF="s48manual_44.html">Arrays</A>
<H2>Queues</H2>
<P>These are ordinary first-in, first-out queues.
The procedures are in structure <CODE>queues</CODE>.
<P><UL><LI><CODE>(make-queue<I></I>)&nbsp;-&gt;&nbsp;<I>queue</I></CODE><A NAME="1">&nbsp;</A>
<LI><CODE>(queue?<I>&nbsp;value</I>)&nbsp;-&gt;&nbsp;<I>boolean</I></CODE><A NAME="2">&nbsp;</A>
<LI><CODE>(queue-empty?<I>&nbsp;queue</I>)&nbsp;-&gt;&nbsp;<I>boolean</I></CODE><A NAME="3">&nbsp;</A>
<LI><CODE>(enqueue!<I>&nbsp;queue&nbsp;value</I>)</CODE><A NAME="4">&nbsp;</A>
<LI><CODE>(dequeue!<I>&nbsp;queue</I>)&nbsp;-&gt;&nbsp;<I>value</I></CODE><A NAME="5">&nbsp;</A>
</UL>
<CODE>Make-queue</CODE> creates an empty queue, <CODE>queue?</CODE> is a predicate for
 identifying queues, <CODE>queue-empty?</CODE> tells you if a queue is empty,
 <CODE>enqueue!</CODE> and <CODE>dequeue!</CODE> add and remove values.
<P><UL><LI><CODE>(queue-length<I>&nbsp;queue</I>)&nbsp;-&gt;&nbsp;<I>integer</I></CODE><A NAME="6">&nbsp;</A>
<LI><CODE>(queue-&gt;list<I>&nbsp;queue</I>)&nbsp;-&gt;&nbsp;<I>values</I></CODE><A NAME="7">&nbsp;</A>
<LI><CODE>(list-&gt;queue<I>&nbsp;values</I>)&nbsp;-&gt;&nbsp;<I>queue</I></CODE><A NAME="8">&nbsp;</A>
<LI><CODE>(delete-from-queue!<I>&nbsp;queue&nbsp;value</I>)&nbsp;-&gt;&nbsp;<I>boolean</I></CODE><A NAME="9">&nbsp;</A>
</UL>
<CODE>Queue-length</CODE> returns the number of values in <I>queue</I>.
<CODE>Queue-&gt;list</CODE> returns the values in <I>queue</I> as a list, in the
 order in which the values were added.
<CODE>List-&gt;queue</CODE> returns a queue containing <I>values</I>, preserving
 their order.
<CODE>Delete-from-queue</CODE> removes the first instance of <I>value</I> from
 <CODE>queue</CODE>, using <CODE>eq?</CODE> for comparisons.
<CODE>Delete-from-queue</CODE> returns <CODE>#t</CODE> if <I>value</I> is found and
 <CODE>#f</CODE> if it is not.
<P><P>
  
Previous: <A HREF="s48manual_42.html">Cells</A> | Next: <A HREF="s48manual_44.html">Arrays</A></BODY></HTML>
